<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <script src="__PUBLIC__/js/jquery-1.9.0.js"></script>
    <script src="__PUBLIC__/js/angular.js"></script>
    <script src="__PUBLIC__/common.js"></script>
    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.css" />
    <!--App自定义的css-->
    <link rel="stylesheet" href="__PUBLIC__/css/app.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/cart.css" />
    <script src="__PUBLIC__/home/plugins/layer/layer.js"></script>
    <script src="__PUBLIC__/common.js"></script>
    <style>
        .cart .cart-goods{
            margin-bottom: 0;
        }
        .cart .media-object {
            line-height: 50px;
            max-width: 50px;
            height: 50px
        }
        .cart .mui-media-body span {
            font-size: 13px;
            width: 100%;
            display: block;
            white-space: normal;
            word-wrap: break-word;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
        }
        html{
            height: 70%;
        }
        body{
            height: 100%;
        }
    </style>
</head>
<body ng-app="myApp" ng-controller="Ctrl" ng-cloak>
<!--header-->
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white"></a>
    <h1 class="mui-title">会员订单</h1>
</header>
<!--购物车-->
<div class="mui-content cart" ng-show="kdflg==0">
    <div style="padding: 4px 2px;background: #ffffff;margin-bottom: 10px">
        <div id="segmentedControl" class="mui-segmented-control"  >
            <a id="st0" class="mui-control-item mui-active">
                全部
            </a>
            <a id="st1" class="mui-control-item">
                未支付
            </a>
            <a id="st2" class="mui-control-item">
                待发货
            </a>
            <a id="st3" class="mui-control-item">
                已发货
            </a>
            <a id="st4" class="mui-control-item">
                已完成
            </a>
        </div>
    </div>
    <ul class="mui-table-view" style="margin-bottom: 10px" ng-repeat="li in message">
        <li class="mui-table-view-cell mui-media cart-goods" style="padding: 2px 1em;font-size: 13px;">
            <div>
                <div style="width:auto; float:left;color: #ef373b">订单号:{{li.sn}}</div>
                <div style="width:auto; float:right;">{{li.createtime}}</div>
            </div>
        </li>
        <div style="width: 100%;height: 1px;background: #c8c7cc;-webkit-transform: scaleY(.5);transform: scaleY(.5);"></div>
        <li class="mui-table-view-cell mui-media cart-goods" style="padding: 2px 1em;font-size: 13px" >
            <div style="width:auto; float:left;">会员:{{li.memberaccount}}</div>
            <button  class="mui-btn mui-btn-danger mui-pull-right" style="width: auto" ng-click="orderdetail(li.id)">查看详情</button>
        </li>
        <li class="mui-table-view-cell mui-media cart-goods" ng-repeat="product in li.goods">
            <a href="javascript:;" style="background: #F6F6F6;"> <img class="media-object mui-pull-left" ng-src="{{product.img}}" />
            <div class="mui-media-body">
                <span>{{product.name}}</span>
                <!--此处数字可传每箱盒数-->
                <p class=" money" style="margin-top: 12px;font-weight: normal">
                    <span class="mui-pull-right" style="text-align: right">
                        <span ng-hide="product.num*1 >= product.boxnum*1">{{product.num}}盒</span>
                        <span ng-show="product.num*1 >= product.boxnum*1">{{floor(product.num/product.boxnum)}}箱{{product.num%product.boxnum}}盒</span>
                    </span>
                    单价:￥<b style="font-weight: normal">{{product.price}}</b>
                </p>
            </div>
            </a> </li>
        <li class="mui-table-view-cell mui-media cart-goods">
            <div style="width: 40%;float: left;height: 33px;line-height: 33px;font-size: 15px;color: #ef373b;font-weight: bold">
                总价:￥{{li.total}}
            </div>
            <div class="mui-content login-tab" style="background: white;width: 60%;float: left" ng-show="{{li.status == 1}}">
                <button class="mui-btn mui-btn-danger mui-pull-right" style="width: 25%;margin-right: 5%" ng-click="cancel(li.id)">驳回</button>
                <button class="mui-btn   mui-pull-right" style="margin-right: 5%" disabled="">未支付</button>

            </div>
            <div class="mui-content login-tab" style="background: white;width: 60%;float: left" ng-show="{{li.status == 2}}">
                <button class="mui-btn mui-btn-danger mui-pull-right" style="font-size:12px; width: 30%;margin-right: 5%" ng-click="delivered(li.id)">发货</button>
                <button class="mui-btn mui-pull-right" style="font-size:12px; width: 40%;margin-right: 5%" disabled="">等待发货</button>
            </div>
            <div class="mui-content login-tab" style="background: white;width: 60%;float: left" ng-show="{{li.status == 3}}">
                <button class="mui-btn mui-btn-danger mui-pull-right" style="width: 45%" ng-click="logistics(li.logistics,li.logisticscom,li.id)">查看物流</button>
                <button class="mui-btn mui-pull-right" style="width: 45%;margin-right: 5%" ng-click="receive(li.id)">已发货</button>
            </div>
            <div class="mui-content login-tab" style="background: white;width: 60%;float: left" ng-show="{{li.status == 4}}">
                <button class="mui-btn   mui-pull-right" style="margin-right: 5%" disabled="">订单完成</button>
            </div>
            <div class="mui-content login-tab" style="background: white;width: 60%;float: left" ng-show="{{li.status == 5}}">
                <button class="mui-btn   mui-pull-right" style="width: 45%;margin-right: 5%" disabled="">已取消</button>
            </div>
            <div class="mui-content login-tab" style="background: white;width: 60%;float: left" ng-show="{{li.status == 6}}">
                <button class="mui-btn   mui-pull-right" style="width: 45%;margin-right: 5%" disabled="">已驳回</button>
            </div>
        </li>
    </ul>
</div>
<div class="mui-content" style="margin-bottom: 50px;height: 100%;" ng-show="kdflg==1">
    <ul class="mui-table-view" style="margin-bottom: 2px">
        <li class="mui-table-view-cell mui-media">
            <div class="mui-content" style="background: white;width: 70%;float: left">
                <button  class="mui-btn  mui-btn-danger mui-pull-right" style="width: 50%;" ng-click="logisticsback()">返回</button>
            </div>
        </li>
    </ul>
    <!--<div style="height: 4px;background:#efeff4; "></div>-->
    <li class="mui-table-view-cell">
        <a>收货人姓名<span class="mui-pull-right">{{lgsts.receivename}}</span></a>
    </li>
    <li class="mui-table-view-cell">
        <a>收货人电话<span class="mui-pull-right">{{lgsts.phone}}</span></a>
    </li>
    <li class="mui-table-view-cell">
        <a>收货人地址<span class="mui-pull-right">{{lgsts.namepath}}</span></a>
    </li>
    <li class="mui-table-view-cell">
        <a>收货人详细地址<span class="mui-pull-right">{{lgsts.address}}</span></a>
    </li>
    <div style="height: 4px;background:#efeff4; "></div>
    <iframe src="" frameborder="0" id="kdshow" name="kdshow" style="width: 100%;height: 100%;" ></iframe>
</div>
<script src="__PUBLIC__/mui/js/mui.min.js"></script>

<include file="./Application/Home/View/pub/agentfoot.html" name="m"/>
<script>
    var app = angular.module('myApp', []);
    app.controller('Ctrl', function($scope,$http) {

        document.getElementById('st0').addEventListener('tap', function () {
            $scope.status=0;
            $scope.loaddata();
        });
        document.getElementById('st1').addEventListener('tap', function () {
            $scope.status=1;
            $scope.loaddata();
        });
        document.getElementById('st2').addEventListener('tap', function () {
            $scope.status=2;
            $scope.loaddata();
        });
        document.getElementById('st3').addEventListener('tap', function () {
            $scope.status=3;
            $scope.loaddata();
        });
        document.getElementById('st4').addEventListener('tap', function () {
            $scope.status=4;
            $scope.loaddata();
        });


        $scope.floor = function(number) {
            return Math.floor(number);
        };

        $scope.loaddata=function () {

            scrolldownloadPost($scope,$http,'/index.php/Home/AgentOnlineorder/memOrder');
        }

        $scope.loaddata();
        // 查看物流flg
        $scope.kdflg = 0

        //驳回
        $scope.cancel=function (id) {
            $http({
                method:'POST',
                data:{'id':id},
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                transformRequest: function(obj) {
                    var str = [];
                    for (var p in obj) {
                        str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                    }
                    return str.join("&");
                },
                url: "/index.php/Home/AgentOnlineorder/cancel"
            }).then(function successCallback(response) {
                if(response.data.code==-1){
                    layer.msg(response.data.msg,{time:1000})
                } else if(response.data.code==0){
                    layer.msg(response.data.msg,{time:1500})
                    setTimeout(function () {
                        window.location.href="/index.php/Home/Agen/mylist"
                    }, 1500)
                }
            }, function errorCallback(response) {
                errorHandle(response);
            });
        }

        //发货
        $scope.delivered=function (id) {
            window.location.href="/index.php/home/agen/sendgoods?id="+id + "&flg=1";
        }

        // 查看物流
        $scope.logistics=function (logistics,com,id) {
            var url = "https://m.kuaidi100.com/index_all.html?type="+com+"&postid="+logistics;
            $('#kdshow').attr('src',url);
            for(var x in $scope.message){
                if($scope.message[x].id == id){
                    $scope.lgsts = $scope.message[x];
                }
            }
            $scope.kdflg = 1;
            //window.location.href="https://www.kuaidi100.com/chaxun?com="+com+"&nu="+id;
        }

        // 查看物流返回
        $scope.logisticsback=function () {
            $scope.kdflg = 0;
        }

        //订单详情
        $scope.orderdetail=function (id) {
            window.location.href= "/index.php/Home/agen/orderdetail?id="+id+"&flg=2"
        }
    })
</script>
</body>
</html>